/**
 *
 */
public class BubbleSort {
    public static void bubbleSort(int[] array){
        //i代表选出来几个最大的||最小的了
        for (int i = 0; i < array.length; i++) {
            boolean s=false;
            for (int j = 0; j < array.length-1-i; j++) {
                if (array[j]>array[j+1]){
                    int tmp=array[j];
                    array[j]=array[j+1];
                    array[j+1]=tmp;
                    s=true;
                }
            }
            if(s==false){
                break;
            }
        }
    }

    public static void main(String[] args) {
        int[] array1={0,5,9,7,8,3,1,2,6,4};
        bubbleSort(array1);
        for (int x :
                array1) {
            System.out.println(x);
        }
    }
}
